home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / SOPEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  706 b   |  28 lines

  1. /* sopen.c --- p 505 */
  2. #include <stdio.h>
  3. #include <io.h>
  4. #include <fcntl.h>
  5. #include <share.h>
  6. #include <sys\stat.h>
  7. main()
  8. {
  9.     int fhandle1, fhandle2;
  10.                     /* Open the file "autoexec.bat." */
  11.     if ( (fhandle1 = sopen("c:\\autoexec.bat",
  12.                      O_RDONLY, SH_DENYRW, S_IREAD)) == -1)
  13.     {
  14.         perror("open failed");
  15.         exit(1);
  16.     }
  17.     printf("AUTOEXEC.BAT opened once. Handle = %d\n", fhandle1);
  18.                             /* Now open again */
  19.     if ( (fhandle2 = sopen("c:autoexec.bat",
  20.                      O_RDONLY, SH_DENYRW, S_IREAD)) == -1)
  21.     {
  22.         perror("open failed");
  23.         printf("SHARE installed\n");
  24.         exit(1);
  25.     }
  26.     printf("AUTOEXEC.BAT open again. Handle = %d\n", fhandle2);
  27.     printf("SHARE has not been installed\n");
  28. }